<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title>地址信息</title>
	<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/reset.css">
    <meta name="description" content="">
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
   <link href="apple-touch-icon.png" rel="apple-touch-icon">
	
	<script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
	<script src="<?php echo IMG_PATH ?>bdkd/js/dizhi_flexible.js"></script>
	 <link href="apple-touch-icon.png" rel="apple-touch-icon">
	 <link href="https://cdn.bootcss.com/framework7/1.6.5/css/framework7.ios.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/framework7/1.6.5/css/framework7.ios.colors.min.css" rel="stylesheet">
    <link href="<?php echo IMG_PATH ?>bdkd/css/dizhi_style.css" rel="stylesheet">
    <style>

        body {
            position: relative;
            background: #f2f2f2;
            height: 100%; }
        body header {
            width: 100%;
            background: #fff; }
        body header ul {
            width: 100%; }
        body header ul li {
            display: flex;
            border-bottom: 1px solid #e3e3e3; }
        body header ul li input {
            display: block;
            padding: 0.4rem;
            width: 100%;
            border: none;
            font-size: 16px;
            color: #999;
            outline: none; }
        [data-dpr="2"] body header ul li input {
            font-size: 32px; }
        [data-dpr="3"] body header ul li input {
            font-size: 48px; }
        body header ul li:nth-child(4) {
            border: none;
            height: 2.26667rem; }
        body header ul li:nth-child(4) textarea {
            padding: 0.4rem;
            border: none;
            width: 100%;
            font-size: 16px;
            color: #999;
            outline: none;
            resize: none; }
        [data-dpr="2"] body header ul li:nth-child(4) textarea {
            font-size: 32px; }
        [data-dpr="3"] body header ul li:nth-child(4) textarea {
            font-size: 48px; }
        body header ul li:nth-child(3) {
            height: 1.17333rem;
            padding: 0.4rem;
            border: none; }
        body section {
            width: 100%;
            padding: 1.30667rem 0px 1.70667rem 0px; }
        body section .btn {
            display: block;
            width: 7.68rem;
            height: 1.2rem;
            background: #14a5fb;
            border: none;
            border-radius: 0.6rem;
            outline: none;
            margin: 0px auto;
            font-size: 14px;
            color: #fff;
            text-align: center;
            line-height: 1.2rem;
            /*box-shadow: 0px 8px 20px 0px rgba(20, 164, 251, 0.44);*/ }
        [data-dpr="2"] body section .btn {
            font-size: 28px; }
        [data-dpr="3"] body section .btn {
            font-size: 42px; }
        body section .btn2 {
            display: block;
            width: 7.68rem;
            height: 1.2rem;
            background: #14a5fb;
            border: none;
            border-radius: 0.6rem;
            outline: none;
            display: none;
            margin: 0px auto;
            font-size: 14px;
            color: #fff;
            text-align: center;
            line-height: 1.2rem;
            box-shadow: 0px 8px 20px 0px rgba(20, 164, 251, 0.44); }
        [data-dpr="2"] body section .btn2 {
            font-size: 28px; }
        [data-dpr="3"] body section .btn2 {
            font-size: 42px; }
        body footer .xuan {
            display: flex;
            width: 100%;
            background: #fff; }
        body footer .xuan .bottom-top {
            width: 100%;
            height: 1.2rem;
            margin: 0px 0.4rem;
            line-height: 1.2rem;
            background-image: url(<?php echo IMG_PATH ?>bdkd/img/xuxian.png);
            background-repeat: no-repeat;
            background-position: bottom;
            background-size: 100%; }
        body footer .xuan .bottom-top p {
            display: inline;
            font-size: 14px;
            padding-left: 0.13333rem;
            color: #333;
            border-left: 0.08rem solid #84bafe; }
        [data-dpr="2"] body footer .xuan .bottom-top p {
            font-size: 28px; }
        [data-dpr="3"] body footer .xuan .bottom-top p {
            font-size: 42px; }
        body footer .dizhi-jiaobu {

            background-image: url(<?php echo IMG_PATH ?>bdkd/img/beijing@2x.png);
            background-size: 3.89333rem 2.98667rem;
            background-position: center;
            background-repeat: no-repeat; }
        body footer .dizhi-jiaobu ul {
            width: 100%;
            height: 5.4rem;
            overflow: scroll;
            /*background:#fff;*/ }
        body footer .dizhi-jiaobu ul li {
            display: flex;
            /*height:1.86667rem;*/
            background: #fff;
            margin-bottom: 0.13333rem; }
        body footer .dizhi-jiaobu ul li div {
            width: 100%;
            padding: 0.4rem;
            display: flex;
            justify-content: space-between;
            flex-direction: column;
            /*  p{
              width: 100%;
            } */ }
        body footer .dizhi-jiaobu ul li div p:nth-child(1) {
            display: flex;
            /*margin-bottom:0.4rem;*/
            justify-content: space-between; }
        body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(1) {
            height: 0.4rem;
            border: none;
            outline: none;
            font-weight: bold;
            font-size: 14px;
            color: #333; }
        [data-dpr="2"] body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(1) {
            font-size: 28px; }
        [data-dpr="3"] body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(1) {
            font-size: 42px; }
        body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(2) {
            width: 2.13333rem;
            height: 0.4rem;
            border: none;
            outline: none;
            font-size: 12px;
            color: #333; }
        [data-dpr="2"] body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(2) {
            font-size: 24px; }
        [data-dpr="3"] body footer .dizhi-jiaobu ul li div p:nth-child(1) input:nth-child(2) {
            font-size: 36px; }
        body footer .dizhi-jiaobu ul li div textarea {
            border: none;
            outline: none;
            font-size: 12px;
            color: #333;
            height: 2rem;
            resize: none; }
        [data-dpr="2"] body footer .dizhi-jiaobu ul li div textarea {
            font-size: 24px; }
        [data-dpr="3"] body footer .dizhi-jiaobu ul li div textarea {
            font-size: 36px; }
        body .bottom {
            width: 100%;
            background: #fff;
            position: fixed;
            bottom: 0;
            display: flex; }
        body .bottom p {
            width: 100%;
            margin: 0px 0.4rem;
            height: 1.06667rem;
            line-height: 1.06667rem;
            font-size: 12px;
            color: #84bafe;
            text-align: center;
            background-image: url(<?php echo IMG_PATH ?>bdkd/img/xuxian.png);
            background-repeat: no-repeat;
            background-position: top;
            background-size: 100%; }
        [data-dpr="2"] body .bottom p {
            font-size: 24px; }
        [data-dpr="3"] body .bottom p {
            font-size: 36px; }


    </style>
	
</head>
<body >

	<header>
        <input type="hidden" name="num" value="<?php echo $num;?>">
        <input type="hidden" name="ipt-rjx" value="<?php echo $type;?>">
		<ul>
			<li>
				<input type="text" name="uname" placeholder="取件人姓名" value="" class="ipt1">
			</li>
			<li>
				<input class="shouji ipt2" type="text" placeholder="手机号码" name="phone" value="" style="border-bottom:none;">
			</li>
			<li class="phone" style="padding:0;border-bottom:1px solid #f2f2f2;border-top:none;">
				<div class="views">
			        <div class="view view-main">
			            <div class="pages">
			                <div class="page" data-page="home">
			                    <div class="hide-tabbar-on-scroll">
			                        <div class="list-block">
			                            <ul>
			                                <li>
			                                    <div class="item-content">
			                                        <div class="item-inner" style="width:100%">
			                                            <div class="item-input">
			                                                <input style="width:320px;" class="ipt4" type="text" value="河北省廊坊市三河市燕郊镇" readonly id="location" name="location">
			                                            </div>
			                                        </div>
			                                    </div>
			                                </li>
			                            </ul>
			                        </div>
			                    </div>
			                    <!-- /.page-content -->
			                </div>
			                <!-- /.page -->
			            </div>
			            <!-- /.pages -->
			        </div>
			        <!-- /.view -->
			    </div>
			    <script src="<?php echo IMG_PATH ?>bdkd/js/jquery.min.js"></script>
			    <script src="<?php echo IMG_PATH ?>bdkd/js/dizhi_framework7.min.js"></script>
			    <script src="<?php echo IMG_PATH ?>bdkd/js/dizhi_regionsObject2.js"></script>
			    <script src="<?php echo IMG_PATH ?>bdkd/js/dizhi_cityPicker.js"></script>
			</li>
			<li>
				<textarea id="address" class="wenbenyu ipt3" placeholder="详细地址(如楼号/单元/门牌号)" value=""></textarea>

			</li>
		</ul>
	</header>


	<section>
	<!-- onclick="window.open('../jikkuaidi/ji.html?path=4')" -->
<!--		<a onclick="window.open('../jikkuaidi/ji.html?path=4')"><div class="btn" onclick="add()">确定</div></a>-->
        <a><div class="btn" onclick="add()">确定</div></a>
	</section>

	<footer class="footer">
		<div class="xuan">
			<div class="bottom-top">
				<p>我的地址</p>
			</div>
		</div>
		
		<div class="dizhi-jiaobu">
             <?php
             if(empty($list)){
                 ?>
                 <img src="<?php echo IMG_PATH ?>bdkd/img/beijing@2x.png" alt="">
                 <?php
             }else{
                 ?>
                 <ul class="chatupian">

                     <?php
                        foreach ($list as $val){
                            //print_r($val);
                            ?>

                            <li>
                                <div>
                                    <p>
                                        <input type="text" readonly="readonly" value="<?php echo $val['name'];?>" class="rjx-shangguan">
                                        <input readonly="readonly" class="rjx-dianhua" type="text" value="<?php echo $val['phone']; ?>">
                                    </p>
                                    <textarea readonly="readonly" class="rjx-dizhi" rows="10"><?php echo $val['addres'];?></textarea>

                                </div>
                            </li>

                            <?php
                        }
                     ?>


                 </ul>
            <?php
             }
             ?>


		</div>
	</footer>
	<script src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.1.min.js"></script>
	<!-- window.open('../jikkuaidi/ji.html') -->

<script type="text/javascript">

    var type = $(" input[ name='ipt-rjx' ] ").val();


    if(type==1){
//        $('.footer').css('display','none');
        $('.views').css('display','none');
        //<input style="width:320px;" class="ipt4" type="text" placeholder="输入详细地址" readonly id="location" name="location">
        var newNode = $("<input style='width:320px;background:#fff;' class='ipt4' type='text' value='河北省廊坊市三河市燕郊镇' disabled='disabled' id='res' name='location'>");
        $('.phone').append(newNode);
    }
    //alert(state);


    $('input').focus(function(){
        $(this).val('').css('color','#333');
    });
    /*手机*/

    $('.shouji').focus(function(){
        $('.shouji').css('color',"#333").val('');
    });
    $('.wenbenyu').focus(function(){
        $(this).val('').css('color','#333');
    })
    $('.shouji').blur(function(){

        var zh=$(this).val();
        var reg=/^1[34578]\d{9}$/;
        var res=reg.test(zh);

        if(!res){
            alert('手机格式有误');
        }
        if(zh===''){
            $('.shouji').val('手机号码')
        }

    });

    $('#location').click(function(){
        // $('#location').css('overflow','hidden');
        $('.chatupian').empty();
    })
    window.onload=function(){
        var rjx = $('.chatupian').children().length;
        if(rjx==0){
            $('.dizhi-jiaobu').css('background-image','<?php echo IMG_PATH ?>bdkd/img/beijing@2x.png');
        }else{
            $('.dizhi-jiaobu').css('background-image','none');
        }
    }
    var oIpt1=document.querySelector(".ipt1");

    var oIpt2=document.querySelector(".ipt2");

    var oIpt3=document.querySelector(".ipt3");
    var oIpt4 =document.querySelector(".ipt4");
    var fcanshu = $(" input[ name='num' ] ").val();

    function qukuaidiadd(){
        if(fcanshu==1){
            var g=localStorage;
            g.setItem('fname',oIpt1.value);
            g.setItem('fdianhua',oIpt2.value);
            g.setItem('fxinxi',oIpt3.value);
        }
    }

    /*zinjiade*/

    function add(){
       // alert(11);
        var name=$.trim($(" input[ name='uname' ] ").val());
        if(name==0){
            alert("请填写姓名");
            return false;
        }
        var phone=$.trim($(" input[ name='phone' ] ").val());
        if(phone==0){
            alert('请填写手机号');
            return false;
        }
        if(type==1){
            var location=$.trim($("#res").val());
        }else {
            var location=$.trim($(" input[name='location']").val());
        }
        if(location==0){
            alert('请选择住址!');
            return false;
        }
        var address=$.trim($("#address").val());
        if(address==0){
            alert('请填写详细地址');
            return false;
        }

        $.ajax({
            url:"<?php echo SITE_PATH ?>work/bexpress/addres",
            type:"post",
            data:{
                'uname': name,
                'phone': phone,
                'location': location,
                'address': address,
                'type':type
            },
            success: function(data){
                console.log(data);
                if(data.result==1){

                    if(fcanshu==1){
                        var g=localStorage;
                        g.setItem('fname',oIpt1.value);
                        g.setItem('fdianhua',oIpt2.value);
                        g.setItem('fxinxi',oIpt3.value);
                        g.setItem('fxxxx',oIpt4.value);
                    }else if(fcanshu==2){
                        var g=localStorage;
                        g.setItem('name',oIpt1.value);
                        g.setItem('dianhua',oIpt2.value);
                        g.setItem('xinxi',oIpt3.value);
                        g.setItem('xxxx',oIpt4.value);
                    }

                    if(fcanshu==5){
                        var g=localStorage;
                        g.setItem('fname',oIpt1.value);
                        g.setItem('fdianhua',oIpt2.value);
                        g.setItem('fxinxi',oIpt3.value);
                        g.setItem('fxxxx',oIpt4.value);
                        //alert(22);
                    }else if(fcanshu==6){
                        var g=localStorage;
                        g.setItem('name',oIpt1.value);
                        g.setItem('dianhua',oIpt2.value);
                        g.setItem('xxxx',oIpt3.value);
                        g.setItem('xinxi',oIpt4.value);
                       // alert(11);
                    }
                    if(fcanshu==7){//取件页面的缓存  4是添加到数据库 上边填写的
                        var g=localStorage;
                        g.setItem('fname',oIpt1.value);
                        g.setItem('fdianhua',oIpt2.value);
                        g.setItem('fxinxi',oIpt3.value);
                        g.setItem('fxxxx',oIpt4.value);
                        //alert(22);
                    }
                    if(fcanshu==1 || fcanshu==2){
                        window.location.href = '<?php echo SITE_PATH ?>work/bexpress/ji?num=4';
                    }
                    if(fcanshu==5 || fcanshu==6){
                        window.location.href = '<?php echo SITE_PATH ?>work/bexpress/wl?num=4';
                    }
                    if(fcanshu==7){

                        window.location.href = '<?php echo SITE_PATH ?>work/bexpress/qk?num=4';
                    }
                }else {
                    alert(data.msg);
                }
            },
            error: function(){
                alert('提交失败0!');
            }
//                async:"false";
        })
    }

    var sg=document.querySelector(".rjx-shangguan");
    var dh=document.querySelector(".rjx-dianhua");
    var dz=document.querySelector(".rjx-dizhi");
    var g=localStorage;

    //点击已有地址时执行
    $('.chatupian li').each(function(index,item){
        console.log(item,index);
        $(item).attr('index',index).click(function(){
        console.log(fcanshu);
            var g=localStorage;

//            window.open('../jikkuaidi/ji.html?path=3');
//            window.location.href = "<?php //echo SITE_PATH ?>//work/bexpress/ji2?type=<?php //echo $num;?>//";

            if(fcanshu==1 || fcanshu==2){
                window.location.href = '<?php echo SITE_PATH ?>work/bexpress/ji?num=3';
            }
            if(fcanshu==5 || fcanshu==6){
                //alert(33);
                window.location.href = '<?php echo SITE_PATH ?>work/bexpress/wl?num=3';
            }
            if(fcanshu==7){//调回取件页面  3是选择下边的地址

                window.location.href = '<?php echo SITE_PATH ?>work/bexpress/qk?num=3';
            }
            if(fcanshu==1 || fcanshu==5 || fcanshu==7){//7为取件页面的缓存

                g.setItem('fRjxName1',$(this).find('.rjx-shangguan').val());
                g.setItem('fRjxDianhua1',$(this).find('.rjx-dianhua').val());
                g.setItem('fRjxDizhi1',$(this).find('.rjx-dizhi').text());
                //alert(123);

            }
            if(fcanshu==2 || fcanshu==6){
                //alert(33);
                g.setItem('sRjxName2',$(this).find('.rjx-shangguan').val());
                g.setItem('sRjxDianhua2',$(this).find('.rjx-dianhua').val());
                g.setItem('sRjxDizhi2',$(this).find('.rjx-dizhi').text());
            }
        });

    })

</script>
</body>
</html>